package com.school.service.impl;

import com.school.dao.PermissionDao;
import com.school.dao.RoleDao;
import com.school.dao.impl.PermissionDaoImpl;
import com.school.dao.impl.RoleDaoImpl;
import com.school.model.Permission;
import com.school.service.PermissionService;
import com.school.service.RoleService;

import java.util.Collection;
import java.util.List;

/**
 * 复杂功能的包装，对数据单元操作进行组装实现复杂功能
 */
public class PermissionServiceImpl implements PermissionService {
    /**
     * 创建数据库访问对象实力
     */
    private PermissionDao userDao = new PermissionDaoImpl();

    @Override
    public Permission insert(Permission permission) {
        return userDao.insert(permission);
    }

    @Override
    public List<Permission> insert(List<Permission> students) {
        return userDao.insert(students);
    }

    @Override
    public void delete(Integer id) {
        userDao.delete(id);
    }

    @Override
    public void delete(Collection<Integer> ids) {
        userDao.delete(ids);
    }

    @Override
    public void update(Permission permission) {
        userDao.update(permission);
    }

    @Override
    public void update(List<Permission> students) {
        userDao.update(students);
    }

    @Override
    public int count() {
        return userDao.count();
    }

    @Override
    public Permission findOneById(Integer id) {
        return userDao.findOneById(id);
    }

    @Override
    public List<Permission> findPage(Permission permission, Integer page, Integer size) {
        // page : 当前页数 5 ，10    0，1，2，3，4
        int offset = (page - 1) * size;
        return userDao.findPage(permission, offset, size);
    }
}
